package java6703.lesson01;

//购物类
public class Shopping6703 {
    public static void main(String[] args) {


         //超市商品
        Product6703[] product6703List = {new Product6703("豆浆机"),
                                         new Product6703("吹风机"),
                                         };

        //打印超市商品清单
//        System.out.println("超市商品清单:"+Arrays.toString(product6703List));

        // 实例化一个超市对象
        Market6703 market6703 = new Market6703("永辉超市", product6703List);



        market6703.setProductList(product6703List);

        //购物清单
        String s1="豆浆机,吹风机";
        //输出购物清单
        System.out.println("张木强的购物清单:"+"["+s1+"]");

        //切割
        String[] s2 = s1.split(",");


        //实例化一个购物者对象
        Person6703 person6703 = new Person6703("张强木");

         //张强木买到的商品

        Product6703[] product6703s = new Product6703[s2.length];
        for (int i=0;i< s2.length;i++){
            product6703s[i]=new Product6703(s2[i]);
        }

        //调用购物者的shopping方法
        String str= person6703.shopping(market6703, product6703s);

        //输出购买结果
        if (s2.length<=1){
            System.out.println("张木强在"+ market6703.getName()+"买到了:"+str);
        }else {
            System.out.println("张木强在"+ market6703.getName() + "买到了:"+ str);
        }
    }
}
